package com.cty.ioc_02;

import org.springframework.beans.factory.config.ConfigurableBeanFactory;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;

@Component
@Scope(scopeName = ConfigurableBeanFactory.SCOPE_PROTOTYPE) //作用域的注解，多例
//@Scope(scopeName = ConfigurableBeanFactory.SCOPE_SINGLETON) //作用域的注解，单例
public class JavaBean {

    //初始化方法
    @PostConstruct //初始化方法的注解
    public void init() {
        System.out.println("javaBean.init");
    }

    @PreDestroy //销毁方法的注解
    public void clear() {
        System.out.println("销毁！！");
    }
}
